package com.itstu.controller;

import com.itstu.annotaion.LoginUser;
import com.itstu.model.AjaxResult;
import com.itstu.pojo.User;
import com.itstu.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 梁卓
 * @Version 1.0
 * @ClassName UserController
 * @Description TODO
 * @Date 2024/09/29 22:33
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping
    public AjaxResult getUserList(@LoginUser User user) {
        return AjaxResult.success(user);
    }

    /**
     * 根据用户名查询用户信息
     * @param username 用户名
     * @return 结果
     */
    @GetMapping("/searchUser")
    public AjaxResult searchUser(String username, @LoginUser User user) {
        User result= userService.getUserByUserName(username);
        return AjaxResult.success(result);
    }
}
